<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Book extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        /*
         * working with helper basic
         */
        $this->load->helper(array('url', 'form'));
        $this->load->model('Book_model');
    }

    public function index()
    {
        $this->load->library('pagination'); // working with pagination

        /*
         * Establish params
         */
        $num_rows = $this->Book_model->rows_count();
        $config['base_url'] = base_url()."index.php/book";
        $config['total_rows'] = $num_rows;
        $config['per_page'] = 3; // limit
        $config['uri_segment'] = 2;

        $start = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0; // get start record

        $this->pagination->initialize($config);

        $data = array(
            'result' => $this->Book_model->fetch_all_book($config['per_page'], $start),
            'link' => $this->pagination->create_links(),
        );


        $this->load->view('vBook/show', $data);

    }

    function search()
    {

    }
}